package com.sx.zongzhi.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sx.zongzhi.R;
import com.sx.zongzhi.adapter.RenterAdapter;
import com.sx.zongzhi.bean.HouseBean;
import com.sx.zongzhi.bean.HouseUserInfo;
import com.sx.zongzhi.bean.MsgEvent;
import com.sx.zongzhi.bean.OrganizingBean;
import com.sx.zongzhi.utils.MyRxBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * 住房成员
 */
public class HouseRenterFragment extends Fragment {

    @BindView(R.id.lisView)
    RecyclerView recyclerView;
    private RenterAdapter renterAdapter;
    private List<HouseUserInfo> renterBeanList=new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_house_renter,container,false);
        ButterKnife.bind(this,view);

        HouseBean houseBean = (HouseBean) getArguments().getSerializable("houseBean");
        initData(houseBean);
        return view;
    }

    public void initData(HouseBean houseBean) {
        if (houseBean == null){
            return;
        }
        renterBeanList.addAll(houseBean.getHousePopulationInfo());
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false));
        renterAdapter = new RenterAdapter(getActivity(),R.layout.item_renter_list,renterBeanList);
        renterAdapter.setEmptyView(View.inflate(getActivity(),R.layout.load_error_view,null));
        recyclerView.setAdapter(renterAdapter);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
